package luoma;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        String str;

        while (true) {
            System.out.println("请输入一个字符串：");
            str = sc.next();
            if (test1(str)) {
                break;
            } else {
                System.out.println("输入错误，请重新输入！");
                continue;
            }
        }
        for (int i = 0; i < str.length(); i++) {
            int num = str.charAt(i) - 48;
            sb.append(beLuoMa(num)+"\t");
        }
        System.out.println(sb);
    }

    public static String beLuoMa(int num) {
        String[] arr = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
        return arr[num];
    }

    public static boolean test1(String str) {
        if (str.length() > 9) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) > '9' || str.charAt(i) <= '0') {
                return false;
            }
        }
        return true;
    }
}
